﻿using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.NetFrame;
using UnityEngine;
using UnityEngine.UI;
using WorldOfSuperpowers_COMMON;
using WorldOfSuperpowers_COMMON.DataModel;

public class LoginManager : MonoBehaviour
{
    public static LoginManager _instance;
    public GameObject loginPanel;
    public GameObject lobbyPanel;

    public InputField usernameInput;
    public InputField passwordInput;

    void Awake()
    {
        _instance = this;
    }

    /// <summary>
    /// 登录按钮事件
    /// </summary>
    public void LoginBtn()
    {
        PhotonPeerManager.GetInstance().SendMessage(OperationCode.Login, GetInputInfo());
        
    }

    /// <summary>
    /// 注册按钮事件
    /// </summary>
    public void RegistBtn()
    {
        PhotonPeerManager.GetInstance().SendMessage(OperationCode.Regist, GetInputInfo());
    }


    public LoginModel GetInputInfo()
    {
        LoginModel model = new LoginModel();
        model.username = usernameInput.text;
        model.password = passwordInput.text;
        usernameInput.text = "";
        passwordInput.text = "";
        return model;
    }

    public void ActiveLoginPanel(bool active)
    {
        loginPanel.SetActive(active);
    }

    public void ActiveLobbyPanel(bool active)
    {

        lobbyPanel.SetActive(active);
    }

}
